import { CrudOptions } from '@nestjsx/crud';
import { HandleStatus } from 'libs/db/entity/enum/handle-status.enum';
import { VillageAction } from 'libs/db/entity/village-action.entity';
import { LoggerInfo, moduleLoggerInfo } from '../_decorator/logger-info';

export const VillageActionCrudOps: CrudOptions = {
  model: {
    type: VillageAction,
  },
  query: {
     
    join: {
      village: {
        exclude: ['createdAt', 'updatedAt', 'deleteAt'],
      },
      'village.town': {
        exclude: ['createdAt', 'updatedAt', 'deleteAt'],
      },
      type: {
        exclude: ['createdAt', 'updatedAt', 'deleteAt'],
      },
      group: {
        exclude:  ["updatedAt", "deleteAt"],
      },
    },
    exclude: ['updatedAt', 'deleteAt'],
  },
  routes: {
    getManyBase: {
      interceptors: [],
      decorators: [
        LoggerInfo(
          new moduleLoggerInfo ('村组织活动查询', HandleStatus.LOG)
        ),
      ],
    },
    getOneBase: {
      interceptors: [],
      decorators: [
        LoggerInfo(
          new moduleLoggerInfo ('单个村组织活动查询', HandleStatus.LOG)
        ),
      ],
    },
    createOneBase: {
      interceptors: [],
      decorators: [
        LoggerInfo(
          new moduleLoggerInfo ('新增村组织活动', HandleStatus.INFO)
        ),
      ],
      returnShallow: true,
    },
    createManyBase: {
      interceptors: [],
      decorators: [
        LoggerInfo(
          new moduleLoggerInfo ('村组织活动信息上传', HandleStatus.DATA)
        ),
      ],
    },
    replaceOneBase: {
      interceptors: [],
      decorators: [
        LoggerInfo(
          new moduleLoggerInfo ('修改村组织活动信息', HandleStatus.WARN)
        ),
      ],
      allowParamsOverride: true,
      returnShallow: true,
    },
    updateOneBase: {
      interceptors: [],
      decorators: [
        LoggerInfo(
          new moduleLoggerInfo ('修改村组织活动信息', HandleStatus.WARN)
        ),
      ],
      allowParamsOverride: true,
      returnShallow: true,
    },
    deleteOneBase: {
      interceptors: [],
      decorators: [
        LoggerInfo(
          new moduleLoggerInfo ('删除村组织活动信息', HandleStatus.ERROR)
        ),
      ],
      returnDeleted: true,
    },
  },
  dto: {
    create: VillageAction,
    replace: VillageAction,
  },
  serialize: {
    getMany: VillageAction,
    get: VillageAction,
    create: VillageAction,
    createMany: VillageAction,
    update: VillageAction,
    replace: VillageAction,
    delete: VillageAction,
  },
};
